﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using HA.ModFlow.Domain.DomainLayer;

namespace HA.ModFlow.Controls
{
    public class PCLPFFlow
    {


        public PCLPFFlow(LPFData lpf)
        {

            this._lpfData = lpf;

            //读取对应的值

            this._clonedCopy = this._lpfData.CloneWithoutDataset();

            this._HDRY = this._lpfData.Parent.HDRY;

            this._IHDWET = this._lpfData.Parent.IHDWET;
            this._IWETIT = this._lpfData.Parent.IWETIT;
            this._WETFCT = this._lpfData.Parent.WETFCT;
            this.CanWet = this._lpfData.Parent.CanWet;
       
        }


        LPFData _lpfData;

        public LPFData LpfData
        {
            get { return _lpfData; }
            set { _lpfData = value; }
        }



        LPFData _clonedCopy;

        public LPFData ClonedCopy
        {
            get { return _clonedCopy; }
            set { _clonedCopy = value; }
        }



        double _HDRY;

        /// <summary>
        /// 干单元的水头值
        /// </summary>
        public double HDRY
        {
            get { return _HDRY; }
            set { _HDRY = value; }
        }



        double _WETFCT;

        /// <summary>
        /// 湿化因子
        /// </summary>
        public double WETFCT
        {
            get { return _WETFCT; }
            set { _WETFCT = value; }
        }

        int _IWETIT;


        /// <summary>
        /// 尝试润湿单元的迭代间隔
        /// </summary>
        public int IWETIT
        {
            get { return _IWETIT; }
            set { _IWETIT = value; }
        }


        int _IHDWET;

        /// <summary>
        /// 
        /// 湿化单元的初始水头计算公式
        /// </summary>
        public int IHDWET
        {
            get { return _IHDWET; }
            set { _IHDWET = value; }
        }

        bool _canWet;

        public bool CanWet
        {
            get { return _canWet; }
            set { _canWet = value; }
        }
    
        public void Confirm()
        {

            this._lpfData.Layers = new List<LPFLayer>();
            foreach (LPFLayer item in this .ClonedCopy.Layers)
            {
                this._lpfData.Layers.Add((LPFLayer)item.Clone());
            }

            this._lpfData.IsConstantCV = this.ClonedCopy.IsConstantCV;
            this._lpfData.IsNoCVCorrection = this.ClonedCopy.IsNoCVCorrection;
            this._lpfData.IsStorageCoefficient = this.ClonedCopy.IsStorageCoefficient;
            this._lpfData.IsThickStrt = this.ClonedCopy.IsThickStrt;
            this._lpfData.Parent.HDRY = this.HDRY;
            this._lpfData.Parent.IHDWET = this._IHDWET;
            this._lpfData.Parent.IWETIT = this._IWETIT;
            this._lpfData.Parent.WETFCT = this._WETFCT;

            if (this._lpfData.Parent.CanWet != this.CanWet)
            {
                this._lpfData.Parent.CanWet = this.CanWet;
                _lpfData.OnLPFDataChanged();
            }
            else
                this._lpfData.Parent.CanWet = this.CanWet;

        
        }

    }
}
